package com.njupt.Array;

import java.util.Arrays;

/**
 * 283. 移动零
 */
public class MoveZeroes {

    public void moveZeroes(int[] nums) {
        int slowIndex = 0;
        for (int fastIndex = 0; fastIndex < nums.length; fastIndex++) {
            if(nums[fastIndex] != 0){
                int temp = nums[fastIndex];
                nums[fastIndex] = nums[slowIndex];
                nums[slowIndex] = temp;
                slowIndex++;
            }

        }
    }

    public static void main(String[] args) {
        int[] nums = {0};
        MoveZeroes test = new MoveZeroes();
        test.moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }
}
